package 蓝桥杯;

import java.util.Scanner;

/**
 * @description:
 * @author: qian
 * @createDate: 2021/11/17
 */
public class 特殊回文数 {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 10000; i <= 999999; i++) {
            String s = String.valueOf(i);
            int l = 0, r = s.length() - 1;
            int mid = (l + r) / 2;
            while (l <= r) {
                if (l <= r && s.charAt(l) == s.charAt(r)) {
                    l++;
                    r--;
                    if (l == mid && s.charAt(l) == s.charAt(r)) {

                        if (division(i) == n) System.out.println(s);
                    }
                }
                if (s.charAt(l) != s.charAt(r)) break;

            }
        }
    }

    // 数位分割
    public static int division(int x) {

        int sum = 0;
        while (x != 0) {
            sum += x % 10;
            x /= 10;
        }
        return sum;

    }
}
